{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 准备工作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T11:33:11.818643Z",
     "start_time": "2020-05-17T11:33:11.724252Z"
    }
   },
   "outputs": [],
   "source": [
    "'''\n",
    "阿里研究院\n",
    "阿里健康\n",
    "阿里巴巴商学院\n",
    "阿里数据\n",
    "\n",
    "腾讯金融科技\n",
    "腾讯研究院\n",
    "腾讯媒体研究院\n",
    "腾讯云启研究院\n",
    "酷鹅用户研究院\n",
    "'''\n",
    "公众号 = \"王者荣耀\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T11:33:11.841579Z",
     "start_time": "2020-05-17T11:33:11.825622Z"
    }
   },
   "outputs": [],
   "source": [
    "fn = { \"output\" : { \"公众号_htm_snippets\": \"data_raw_src/公众号_htm_snippets_{公众号}.tsv\",\n",
    "                    \"公众号_df\": \"data_raw_src/公众号_df_{公众号}.tsv\",\n",
    "                    \"公众号_xlsx\": \"data_sets/公众号_url_{公众号}.xlsx\" } \\\n",
    "      }"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 采集公众号（requests）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:17:12.799030Z",
     "start_time": "2020-05-17T13:17:06.029255Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "'app_msg_list'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-76-87ebc390f32b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     39\u001b[0m \u001b[1;31m#     print(content_json)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     40\u001b[0m     \u001b[1;31m# 返回了一个json，里面是每一页的数据\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 41\u001b[1;33m     \u001b[1;32mfor\u001b[0m \u001b[0mitem\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mcontent_json\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"app_msg_list\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     42\u001b[0m     \u001b[1;31m# 提取每页文章的标题及对应的url\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     43\u001b[0m         \u001b[0mitems\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'app_msg_list'"
     ]
    }
   ],
   "source": [
    "# 目标url\n",
    "\n",
    "import time\n",
    "import requests\n",
    "import pandas as pd\n",
    "import csv\n",
    "\n",
    "\n",
    "url = \"https://mp.weixin.qq.com/cgi-bin/appmsg\"\n",
    "\n",
    "# 使用Cookie，跳过登陆操作\n",
    "headers = {\n",
    "  \"Cookie\": \"pgv_pvi=7968112640; RK=dAxoOkmNPM; ptcz=5e911a8738788675abb010f85db7a6c13b0570811db08ebefce3d01adfff5127; tvfe_boss_uuid=35a8107e1f02cbf7; pgv_pvid=160875890; o_cookie=576726974; pgv_si=s7389809664; uin=o0576726974; skey=@biD9HkZPV; ptisp=ctc; ua_id=o954FR4YG9aIylgbAAAAAAG1mFSkee-v8r6HcCv6PUM=; cert=xdo33QVRQxDDEATQOxVPYZVSl8hcgbBw; noticeLoginFlag=1; xid=; openid2ticket_omd36wPk8CgeWUiAccw6ZoK6cfKM=V9b+6gaDppAhuzkBsqQ2cqmVOoVbPExAl/fu+rqQ2xk=; mm_lang=zh_CN; rewardsn=; wxtokenkey=777; uuid=3f563116b647ce9a578c8d004d3508a8; ticket=a4fe0acfed322dd3eff3a301d94afded6dac3be0; ticket_id=gh_b8ce1853cd9b; rand_info=CAESIIpFhkwqorHCev9Vkx8d1xoS/h28VHdI65d1I+hS8rYh; slave_bizuin=3252904960; data_bizuin=3509374721; bizuin=3252904960; data_ticket=6z/ln+jO+jKPoA5MKzm3D6Cbfkg41cD9D6v6HTaHq8//2C9Hk73W6LtQlNMXteTT; slave_sid=eWpTNFJYU0hHQUFtcUt1TnBGSEZDYU55bHJXX2hhTTlZa3hvcno4MFRNaGd2QUlIT2Vxb0xHUmRWc1RQV2txQkI3OXFlUXhuOWY1aGVYbWdvTGFpNzNhTTdNaGhaRWNWNmwzTmFMRWlEa25Pa0VkZGpwVGkxNTRUdmRTbEtpbGF2UFUwbEZJR0lHdnlBcDFs; slave_user=gh_b8ce1853cd9b; openid2ticket_oAc8s0T6rPCr8qnMO7SoANf_3jVI=LJrk/Pum+BnDCZRPacwc+RgFKJv/+2uJEUtvOa1gdTU=\",\n",
    "  \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36\"}\n",
    "\n",
    "data = {\n",
    "    \"token\": \"1119521086\",\n",
    "    \"lang\": \"zh_CN\",\n",
    "    \"f\": \"json\",\n",
    "    \"ajax\": \"1\",\n",
    "    \"action\": \"list_ex\",\n",
    "    \"begin\": \"0\",\n",
    "    \"count\": \"5\",\n",
    "    \"query\": \"\",\n",
    "    \"fakeid\": \"MzI0Nzc3MTQyMw==\",\n",
    "    \"type\": \"9\",\n",
    "}\n",
    "\n",
    "\n",
    "\n",
    "content_list=[]\n",
    "\n",
    "for i in range(5):\n",
    "    data[\"begin\"] = i*5\n",
    "    print(data[\"begin\"])\n",
    "    time.sleep(3)\n",
    "    # 使用get方法进行提交\n",
    "    content_json = requests.get(url, headers=headers, params=data).json()\n",
    "#     print(content_json)\n",
    "    # 返回了一个json，里面是每一页的数据\n",
    "    for item in content_json[\"app_msg_list\"]:\n",
    "    # 提取每页文章的标题及对应的url\n",
    "        items = []\n",
    "        items.append(item[\"title\"])\n",
    "        items.append(item[\"link\"])\n",
    "        items.append(item[\"create_time\"])\n",
    "        content_list.append(items)\n",
    "\n",
    "\n",
    "name=['title','link','create_time']\n",
    "test=pd.DataFrame(columns=name,data=content_list)\n",
    "with pd.ExcelWriter(fn[\"output\"][\"公众号_xlsx\"].format(公众号=\"_requests\")) as writer:\n",
    "    test.to_excel(writer)\n",
    "\n",
    "# test.to_csv(\"../微信公众号爬虫_zhichao/南方周末.csv\",mode='a',encoding='utf-8')\n",
    "# print(\"保存成功\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 采集公众号（selenium）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:11:49.389813Z",
     "start_time": "2020-05-17T12:11:49.385824Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from lxml.html import fromstring\n",
    "import time\n",
    "from random import random\n",
    "\n",
    "# when selenium main_content is used\n",
    "# Parses an HTML document from a string constant.  Returns the root nood\n",
    "# root = fromstring(df.loc[1,\"html_snippets\"]) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 使用Selenium\n",
    "* 要更改 opts.binary_location 至自己本地的Chrome浏览器，建议portable\n",
    "* Chrome浏览器 和 chromedriver.exe要同版本号到小数后一位\n",
    "* 要确保可以 开启浏览器机器人\n",
    "* 要确保浏览器机器人 可以打开网页 driver.get(\"https://mp.weixin.qq.com\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:11:57.190820Z",
     "start_time": "2020-05-17T12:11:53.493162Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda3\\envs\\pan\\lib\\site-packages\\ipykernel_launcher.py:18: DeprecationWarning: use options instead of chrome_options\n"
     ]
    }
   ],
   "source": [
    "from selenium import webdriver\n",
    "from selenium.webdriver.common.desired_capabilities import DesiredCapabilities\n",
    "\n",
    "#caps=dict()\n",
    "#caps[\"pageLoadStrategy\"] = \"none\"   # Do not wait for full page load\n",
    "\n",
    "opts = webdriver.ChromeOptions()\n",
    "opts.add_argument('--no-sandbox')#解决DevToolsActivePort文件不存在的报错\n",
    "opts.add_argument('window-size=1920x3000') #指定浏览器分辨率\n",
    "opts.add_argument('--disable-gpu') #谷歌文档提到需要加上一这个属性来规避bug\n",
    "opts.add_argument('--hide-scrollbars') #隐藏滚动条, 应对些特殊页面\n",
    "#opts.add_argument('blink-settings=imagesEnabled=false') #不加载图片, 提升速度\n",
    "#opts.add_argument('--headless') #浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败\n",
    "\n",
    "opts.binary_location = r\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" #\"H:\\_coding_\\Gitee\\InternetNewMedia\\CapstonePrj2016\\chromedriver.exe\"  \n",
    "\n",
    "# \"H:\\_coding_\\Gitee\\InternetNewMedia\\CapstonePrj2016\\chromedriver.exe\"  \n",
    "driver = webdriver.Chrome( chrome_options = opts) #desired_capabilities=caps,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:05.284726Z",
     "start_time": "2020-05-17T12:12:04.423720Z"
    }
   },
   "outputs": [],
   "source": [
    "driver.get(\"https://mp.weixin.qq.com\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 填表登入"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "selenium 的定位方法\n",
    "* find_element_by_id &ensp;&ensp;&ensp;  根据标签id定位\n",
    "* find_element_by_name   &ensp;&ensp;&ensp; 根据标签的name定位\n",
    "* find_element_by_xpath  &ensp;&ensp;&ensp; 根据xpath定位\n",
    "* find_element_by_link_text  &ensp;&ensp;&ensp; 通过文字链接来定位元素\n",
    "* find_element_by_partial_link_text  &ensp;&ensp;&ensp;  通过文字链接来定位元素\n",
    "* find_element_by_tag_name  &ensp;&ensp;&ensp;  根据标签的名字定位\n",
    "* find_element_by_class_name  &ensp;&ensp;&ensp; 通过class name 定位\n",
    "* find_element_by_css_selector  &ensp;&ensp;&ensp;  根据元素属性来定位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:09.014833Z",
     "start_time": "2020-05-17T12:12:08.800799Z"
    }
   },
   "outputs": [],
   "source": [
    "payload =  {\"account\": \"516265427@qq.com\", \"password\": \"T0918zyi.\"}\n",
    "# payload =  {\"account\": \"NFUHacks@163.com\", \"password\": \"NFU706947580\"}\n",
    "driver.find_element_by_xpath('//div[@class=\"login__type__container login__type__container__scan\"]/a').click()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "WebDriver 常用方法：\n",
    "* clear()清楚文本\n",
    "* send_keys(values)模拟按键输入\n",
    "* click()模拟点击\n",
    "* submit模拟提交"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:13.458131Z",
     "start_time": "2020-05-17T12:12:13.146702Z"
    }
   },
   "outputs": [],
   "source": [
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"account\"]').clear()\n",
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"account\"]').send_keys(payload['account'])\n",
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"password\"]').clear()\n",
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"password\"]').send_keys(payload['password'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:16.897299Z",
     "start_time": "2020-05-17T12:12:16.846672Z"
    }
   },
   "outputs": [],
   "source": [
    "driver.find_element_by_xpath('//div[@class=\"login_btn_panel\"]/a').click()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 点选单"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "其他常用方法\n",
    "* size：返回元素的尺寸\n",
    "* text：获取元素的文本\n",
    "* get_attribute：获取属性值  &ensp;&ensp;&ensp; get_attribute('innerHTML')获取元素内的全部HTML\n",
    "* is_displayed()：设置该元素用户是否可见"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:33.041029Z",
     "start_time": "2020-05-17T12:12:32.976117Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'展开'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "element = driver.find_element_by_xpath('//a[@id=\"m_open\"]')\n",
    "element.click()\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "main_content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:39.263913Z",
     "start_time": "2020-05-17T12:12:39.253987Z"
    }
   },
   "outputs": [],
   "source": [
    "driver.execute_script(\"window.scrollTo(0,document.body.scrollHeight)\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:12:42.887664Z",
     "start_time": "2020-05-17T12:12:42.869318Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'https://mp.weixin.qq.com/cgi-bin/appmsg?begin=0&count=10&t=media/appmsg_list&type=10&action=list&token=1915885272&lang=zh_CN'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "element = driver.find_element_by_xpath('//li[@title[contains(.,\"素材管理\")]]/a') \n",
    "# main_content = element.get_attribute('innerHTML')\n",
    "# main_content\n",
    "url2= element.get_attribute(\"href\")\n",
    "url2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:32:08.782811Z",
     "start_time": "2020-05-17T12:32:05.886477Z"
    }
   },
   "outputs": [],
   "source": [
    "driver.get(url2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 新建图文消息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:32:42.410241Z",
     "start_time": "2020-05-17T12:32:42.321910Z"
    }
   },
   "outputs": [],
   "source": [
    "element = driver.find_element_by_xpath('//*[text()[contains(.,\"新建图文消息\")]]') \n",
    "main_content = element.get_attribute('innerHTML')\n",
    "main_content\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:32:47.359910Z",
     "start_time": "2020-05-17T12:32:47.039793Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['CDwindow-A4DC3372331FE50D26BF937F2EE4EF3C', 'CDwindow-1246C66736427198836C12DD26F26B19']\n"
     ]
    }
   ],
   "source": [
    "print (driver.window_handles)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:32:48.559834Z",
     "start_time": "2020-05-17T12:32:48.547266Z"
    }
   },
   "outputs": [],
   "source": [
    "# 新建图文消息开了另一分视窗，所以要切换 switch_to \n",
    "driver.switch_to.window(driver.window_handles[-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 超链接"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:33:12.568733Z",
     "start_time": "2020-05-17T12:33:10.364441Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                超链接              \n"
     ]
    }
   ],
   "source": [
    "element = driver.find_element_by_xpath('//*[text()[contains(.,\"超链接\")]]') \n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:33:18.094356Z",
     "start_time": "2020-05-17T12:33:18.029788Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "选择其他公众号\n"
     ]
    }
   ],
   "source": [
    "# 点 选择其他公众号\n",
    "element = driver.find_element_by_xpath('//*[text()[contains(.,\"选择其他公众号\")]]') \n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:33:26.376796Z",
     "start_time": "2020-05-17T12:33:26.259006Z"
    }
   },
   "outputs": [],
   "source": [
    "driver.find_element_by_xpath('//form//div[@class=\"inner_link_account_area\"]//input[@class=\"weui-desktop-form__input\"]').clear()\n",
    "driver.find_element_by_xpath('//form//div[@class=\"inner_link_account_area\"]//input[@class=\"weui-desktop-form__input\"]').send_keys(公众号)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:40:38.122795Z",
     "start_time": "2020-05-17T12:40:38.059489Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<div class=\"weui-desktop-icon weui-desktop-icon__inputSearch weui-desktop-icon__small\"><!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M11.33 10.007l4.273 4.273a.502.502 0 0 1 .005.709l-.585.584a.499.499 0 0 1-.709-.004L10.046 11.3a6.278 6.278 0 1 1 1.284-1.294zm.012-3.729a5.063 5.063 0 1 0-10.127 0 5.063 5.063 0 0 0 10.127 0z\"></path></svg> <!----> <!----> <!----> <!----></div>\n"
     ]
    }
   ],
   "source": [
    "# 点放大镜搜\n",
    "element = driver.find_element_by_xpath('//button[@class=\"weui-desktop-icon-btn weui-desktop-search__btn\"]')\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:40:45.679191Z",
     "start_time": "2020-05-17T12:40:45.656659Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/LvM7ibdRGl1sPsq5Ytwe6X70NPu3h7wE9UkpIxWGP3SPzpXZRCR2ksHc38hocMzwuOVqRNKC5dgQiaibl9cic7eGhQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">王者荣耀</strong> <i class=\"inner_link_account_wechat\">微信号：heromoba</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/TR25ticLmv3XwmlUDmlVEcWnPxu5prO4DlPo9fhpBtPq9LQyqgnjdNmnFpZBib9lcd8hqyjwRH2MJwRaEia6vGjUQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">王者礼包荣耀skin</strong> <i class=\"inner_link_account_wechat\">微信号：fulvqi</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/HFRpia2icx7IAhpQbFEnY9lnsNegNTMrPuaELsmFp1QRDRCPHicEJIG9Yb3ZswAicFKqjhztypJfvz8bjFW2RTXerQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">KPL王者荣耀职业联赛</strong> <i class=\"inner_link_account_wechat\">微信号：wzrykpl</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/ibGpblh4qGJQVzZ825ND2GuGsyicHA2WTmf4hmureWQfnTdia4au2pFhY4WVFW1scFl8LgmwWegvCSfPpCwXXp8Zw/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">王者之荣耀福利社</strong> <i class=\"inner_link_account_wechat\">微信号：svip888q</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/IXqEhcKA2MOwMuxndOhRKBic0MliaeoD32ffM8F1dsnyx5QVPbFlTxxYJicvRhJX44eDh4TiaNCHgh3f73ZIp8NDpQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">王者礼包荣耀点券</strong> <i class=\"inner_link_account_wechat\">微信号：dilireba365</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li>\n"
     ]
    }
   ],
   "source": [
    "element = driver.find_element_by_xpath('//ul[@class=\"inner_link_account_list\"]')\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "公众号SERP = main_content\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:40:55.800496Z",
     "start_time": "2020-05-17T12:40:55.698315Z"
    }
   },
   "outputs": [],
   "source": [
    "# 解析\n",
    "root = fromstring(公众号SERP) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:40:59.660073Z",
     "start_time": "2020-05-17T12:40:59.539049Z"
    }
   },
   "outputs": [],
   "source": [
    "主 = root.xpath('//li[@class=\"inner_link_account_item\"]')\n",
    "\n",
    "account_list = []\n",
    "for e in 主:\n",
    "    account_nickname = e.xpath('./div/strong[@class=\"inner_link_account_nickname\"]')[0].text\n",
    "    account_wechat = e.xpath('./div/i[@class=\"inner_link_account_wechat\"]')[0].text\n",
    "    account_img = e.xpath('./div/img/@src')[0]\n",
    "    account = {\"nickname\": account_nickname, \"wechat\": account_wechat, \"img\": account_img,}\n",
    "    account_list.append(account)\n",
    "\n",
    "df_account = pd.DataFrame(account_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:41:00.513451Z",
     "start_time": "2020-05-17T12:41:00.388919Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>nickname</th>\n",
       "      <th>wechat</th>\n",
       "      <th>img</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>王者荣耀</td>\n",
       "      <td>微信号：heromoba</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/LvM7ibdRGl1sPsq...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>王者礼包荣耀skin</td>\n",
       "      <td>微信号：fulvqi</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/TR25ticLmv3Xwml...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>KPL王者荣耀职业联赛</td>\n",
       "      <td>微信号：wzrykpl</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/HFRpia2icx7IAhp...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>王者之荣耀福利社</td>\n",
       "      <td>微信号：svip888q</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/ibGpblh4qGJQVzZ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>王者礼包荣耀点券</td>\n",
       "      <td>微信号：dilireba365</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/IXqEhcKA2MOwMux...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      nickname           wechat  \\\n",
       "0         王者荣耀     微信号：heromoba   \n",
       "1   王者礼包荣耀skin       微信号：fulvqi   \n",
       "2  KPL王者荣耀职业联赛      微信号：wzrykpl   \n",
       "3     王者之荣耀福利社     微信号：svip888q   \n",
       "4     王者礼包荣耀点券  微信号：dilireba365   \n",
       "\n",
       "                                                 img  \n",
       "0  http://mmbiz.qpic.cn/mmbiz_png/LvM7ibdRGl1sPsq...  \n",
       "1  http://mmbiz.qpic.cn/mmbiz_png/TR25ticLmv3Xwml...  \n",
       "2  http://mmbiz.qpic.cn/mmbiz_png/HFRpia2icx7IAhp...  \n",
       "3  http://mmbiz.qpic.cn/mmbiz_png/ibGpblh4qGJQVzZ...  \n",
       "4  http://mmbiz.qpic.cn/mmbiz_png/IXqEhcKA2MOwMux...  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_account"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:41:04.171493Z",
     "start_time": "2020-05-17T12:41:04.103591Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/LvM7ibdRGl1sPsq5Ytwe6X70NPu3h7wE9UkpIxWGP3SPzpXZRCR2ksHc38hocMzwuOVqRNKC5dgQiaibl9cic7eGhQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">王者荣耀</strong> <i class=\"inner_link_account_wechat\">微信号：heromoba</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div>\n"
     ]
    }
   ],
   "source": [
    "element = driver.find_element_by_xpath('//ul[@class=\"inner_link_account_list\"]/li')\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:41:09.361687Z",
     "start_time": "2020-05-17T12:41:09.357697Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n跳转_input = driver.find_element_by_xpath(\\'//span[@class=\"weui-desktop-pagination__form\"]/input\\')\\n跳转_a = driver.find_element_by_xpath(\\'//span[@class=\"weui-desktop-pagination__form\"]/a\\')\\n跳转_input.clear()\\n跳转_input.send_keys(2)\\n跳转_a.click()\\n'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 跳转testing\n",
    "'''\n",
    "跳转_input = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/input')\n",
    "跳转_a = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/a')\n",
    "跳转_input.clear()\n",
    "跳转_input.send_keys(2)\n",
    "跳转_a.click()\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:41:10.740616Z",
     "start_time": "2020-05-17T12:41:10.623769Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 303]\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "# 跳转上限\n",
    "l_e = driver.find_elements_by_xpath('//label[@class=\"weui-desktop-pagination__num\"]')\n",
    "l_e_int  = [int(x.text) for x in l_e] \n",
    "print (l_e_int)\n",
    "print (l_e_int[0]==l_e_int[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:41:11.756423Z",
     "start_time": "2020-05-17T12:41:11.752580Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303]\n"
     ]
    }
   ],
   "source": [
    "pages = list(range(l_e_int[0],l_e_int[-1]+1 ))\n",
    "#print(pages[0:2])\n",
    "pages = list(range(1,l_e_int[-1]+1 ))\n",
    "print(pages)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 循环/遍历"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:41:14.878457Z",
     "start_time": "2020-05-17T12:41:14.875192Z"
    }
   },
   "outputs": [],
   "source": [
    "# global varialbes \n",
    "html_raw = dict()\n",
    "main_content =\"\"\n",
    "element = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T12:43:57.305429Z",
     "start_time": "2020-05-17T12:43:57.300415Z"
    }
   },
   "outputs": [],
   "source": [
    "def process_pages (pages):\n",
    "    for p in pages:\n",
    "        print (p,end='\\t')\n",
    "\n",
    "        跳转_input = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/input')\n",
    "        跳转_a = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/a')\n",
    "        跳转_input.clear()\n",
    "        跳转_input.send_keys(p)\n",
    "        跳转_a.click()\n",
    "\n",
    "        time.sleep(3+1*random())\n",
    "\n",
    "        element = driver.find_element_by_xpath('//div[@class=\"inner_link_article_list\"]')\n",
    "        main_content = element.get_attribute('innerHTML')\n",
    "        #print(main_content)\n",
    "        html_raw[p] = main_content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:02:31.209761Z",
     "start_time": "2020-05-17T12:43:58.010324Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\t27\t28\t29\t30\t31\t32\t33\t34\t35\t36\t37\t38\t39\t40\t41\t42\t43\t44\t45\t46\t47\t48\t49\t50\t51\t52\t53\t54\t55\t56\t57\t58\t59\t60\t61\t62\t63\t64\t65\t66\t67\t68\t69\t70\t71\t72\t73\t74\t75\t76\t77\t78\t79\t80\t81\t82\t83\t84\t85\t86\t87\t88\t89\t90\t91\t92\t93\t94\t95\t96\t97\t98\t99\t100\t101\t102\t103\t104\t105\t106\t107\t108\t109\t110\t111\t112\t113\t114\t115\t116\t117\t118\t119\t120\t121\t122\t123\t124\t125\t126\t127\t128\t129\t130\t131\t132\t133\t134\t135\t136\t137\t138\t139\t140\t141\t142\t143\t144\t145\t146\t147\t148\t149\t150\t151\t152\t153\t154\t155\t156\t157\t158\t159\t160\t161\t162\t163\t164\t165\t166\t167\t168\t169\t170\t171\t172\t173\t174\t175\t176\t177\t178\t179\t180\t181\t182\t183\t184\t185\t186\t187\t188\t189\t190\t191\t192\t193\t194\t195\t196\t197\t198\t199\t200\t201\t202\t203\t204\t205\t206\t207\t208\t209\t210\t211\t212\t213\t214\t215\t216\t217\t218\t219\t220\t221\t222\t223\t224\t225\t226\t227\t228\t229\t230\t231\t232\t233\t234\t235\t236\t237\t238\t239\t240\t241\t242\t243\t244\t245\t246\t247\t248\t249\t250\t251\t252\t253\t254\t255\t256\t257\t258\t259\t260\t261\t262\t263\t264\t265\t266\t267\t268\t269\t270\t271\t272\t273\t274\t275\t276\t277\t278\t279\t280\t281\t282\t283\t284\t285\t286\t287\t288\t289\t290\t291\t292\t293\t294\t295\t296\t297\t298\t299\t300\t301\t302\t303\t"
     ]
    }
   ],
   "source": [
    "process_pages(pages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:20.405778Z",
     "start_time": "2020-05-17T13:07:20.344093Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>html_snippets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>301</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>302</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>303</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>303 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         html_snippets\n",
       "1    <div><label class=\"inner_link_article_item\"><s...\n",
       "2    <div><label class=\"inner_link_article_item\"><s...\n",
       "3    <div><label class=\"inner_link_article_item\"><s...\n",
       "4    <div><label class=\"inner_link_article_item\"><s...\n",
       "5    <div><label class=\"inner_link_article_item\"><s...\n",
       "..                                                 ...\n",
       "299  <div><label class=\"inner_link_article_item\"><s...\n",
       "300  <div><label class=\"inner_link_article_item\"><s...\n",
       "301  <div><label class=\"inner_link_article_item\"><s...\n",
       "302  <div><label class=\"inner_link_article_item\"><s...\n",
       "303  <div><label class=\"inner_link_article_item\"><s...\n",
       "\n",
       "[303 rows x 1 columns]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame([html_raw]).T\n",
    "df.columns = [\"html_snippets\"]\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:23.714246Z",
     "start_time": "2020-05-17T13:07:23.594673Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stored 'html_raw' (dict)\n"
     ]
    }
   ],
   "source": [
    "%store html_raw\n",
    "import pickle \n",
    "filehandler = open(\"html_raw\", 'wb') \n",
    "pickle.dump(html_raw, filehandler)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:25.196818Z",
     "start_time": "2020-05-17T13:07:25.088356Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "61\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>html_snippets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>301</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>302</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>303</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>242 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         html_snippets\n",
       "11   <div><label class=\"inner_link_article_item\"><s...\n",
       "34   <div><label class=\"inner_link_article_item\"><s...\n",
       "35   <div><label class=\"inner_link_article_item\"><s...\n",
       "36   <div><label class=\"inner_link_article_item\"><s...\n",
       "37   <div><label class=\"inner_link_article_item\"><s...\n",
       "..                                                 ...\n",
       "299  <div><label class=\"inner_link_article_item\"><s...\n",
       "300  <div><label class=\"inner_link_article_item\"><s...\n",
       "301  <div><label class=\"inner_link_article_item\"><s...\n",
       "302  <div><label class=\"inner_link_article_item\"><s...\n",
       "303  <div><label class=\"inner_link_article_item\"><s...\n",
       "\n",
       "[242 rows x 1 columns]"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_out = df[~df.duplicated()]\n",
    "print (len(df_out))\n",
    "df[df.duplicated()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:30.515839Z",
     "start_time": "2020-05-17T13:07:30.429863Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[11,\n",
       " 34,\n",
       " 35,\n",
       " 36,\n",
       " 37,\n",
       " 38,\n",
       " 39,\n",
       " 40,\n",
       " 41,\n",
       " 42,\n",
       " 43,\n",
       " 44,\n",
       " 45,\n",
       " 46,\n",
       " 47,\n",
       " 48,\n",
       " 49,\n",
       " 50,\n",
       " 51,\n",
       " 52,\n",
       " 53,\n",
       " 54,\n",
       " 55,\n",
       " 56,\n",
       " 57,\n",
       " 58,\n",
       " 59,\n",
       " 60,\n",
       " 61,\n",
       " 62,\n",
       " 63,\n",
       " 64,\n",
       " 65,\n",
       " 66,\n",
       " 67,\n",
       " 68,\n",
       " 69,\n",
       " 70,\n",
       " 71,\n",
       " 72,\n",
       " 73,\n",
       " 74,\n",
       " 75,\n",
       " 76,\n",
       " 77,\n",
       " 78,\n",
       " 79,\n",
       " 80,\n",
       " 81,\n",
       " 82,\n",
       " 83,\n",
       " 84,\n",
       " 85,\n",
       " 86,\n",
       " 87,\n",
       " 88,\n",
       " 89,\n",
       " 90,\n",
       " 91,\n",
       " 92,\n",
       " 93,\n",
       " 94,\n",
       " 95,\n",
       " 96,\n",
       " 97,\n",
       " 98,\n",
       " 99,\n",
       " 100,\n",
       " 101,\n",
       " 102,\n",
       " 103,\n",
       " 104,\n",
       " 105,\n",
       " 106,\n",
       " 107,\n",
       " 108,\n",
       " 109,\n",
       " 110,\n",
       " 111,\n",
       " 112,\n",
       " 113,\n",
       " 114,\n",
       " 144,\n",
       " 145,\n",
       " 146,\n",
       " 147,\n",
       " 148,\n",
       " 149,\n",
       " 150,\n",
       " 151,\n",
       " 152,\n",
       " 153,\n",
       " 154,\n",
       " 155,\n",
       " 156,\n",
       " 157,\n",
       " 158,\n",
       " 159,\n",
       " 160,\n",
       " 161,\n",
       " 162,\n",
       " 163,\n",
       " 164,\n",
       " 165,\n",
       " 166,\n",
       " 167,\n",
       " 168,\n",
       " 169,\n",
       " 170,\n",
       " 171,\n",
       " 172,\n",
       " 173,\n",
       " 174,\n",
       " 175,\n",
       " 176,\n",
       " 177,\n",
       " 178,\n",
       " 179,\n",
       " 180,\n",
       " 181,\n",
       " 182,\n",
       " 183,\n",
       " 184,\n",
       " 185,\n",
       " 186,\n",
       " 187,\n",
       " 188,\n",
       " 189,\n",
       " 190,\n",
       " 191,\n",
       " 192,\n",
       " 193,\n",
       " 194,\n",
       " 195,\n",
       " 196,\n",
       " 197,\n",
       " 198,\n",
       " 199,\n",
       " 200,\n",
       " 201,\n",
       " 202,\n",
       " 203,\n",
       " 204,\n",
       " 205,\n",
       " 206,\n",
       " 207,\n",
       " 208,\n",
       " 209,\n",
       " 210,\n",
       " 211,\n",
       " 212,\n",
       " 213,\n",
       " 214,\n",
       " 215,\n",
       " 216,\n",
       " 217,\n",
       " 218,\n",
       " 219,\n",
       " 220,\n",
       " 221,\n",
       " 222,\n",
       " 223,\n",
       " 224,\n",
       " 225,\n",
       " 226,\n",
       " 227,\n",
       " 228,\n",
       " 229,\n",
       " 230,\n",
       " 231,\n",
       " 232,\n",
       " 233,\n",
       " 234,\n",
       " 235,\n",
       " 236,\n",
       " 237,\n",
       " 238,\n",
       " 239,\n",
       " 240,\n",
       " 241,\n",
       " 242,\n",
       " 243,\n",
       " 244,\n",
       " 245,\n",
       " 246,\n",
       " 247,\n",
       " 248,\n",
       " 249,\n",
       " 250,\n",
       " 251,\n",
       " 252,\n",
       " 253,\n",
       " 254,\n",
       " 255,\n",
       " 256,\n",
       " 257,\n",
       " 258,\n",
       " 259,\n",
       " 260,\n",
       " 261,\n",
       " 262,\n",
       " 263,\n",
       " 264,\n",
       " 265,\n",
       " 266,\n",
       " 267,\n",
       " 268,\n",
       " 269,\n",
       " 270,\n",
       " 271,\n",
       " 272,\n",
       " 273,\n",
       " 274,\n",
       " 275,\n",
       " 276,\n",
       " 277,\n",
       " 278,\n",
       " 279,\n",
       " 280,\n",
       " 281,\n",
       " 282,\n",
       " 283,\n",
       " 284,\n",
       " 285,\n",
       " 286,\n",
       " 287,\n",
       " 288,\n",
       " 289,\n",
       " 290,\n",
       " 291,\n",
       " 292,\n",
       " 293,\n",
       " 294,\n",
       " 295,\n",
       " 296,\n",
       " 297,\n",
       " 298,\n",
       " 299,\n",
       " 300,\n",
       " 301,\n",
       " 302,\n",
       " 303]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "try_again = list(df[df.duplicated()].index)\n",
    "print(try_again)\n",
    "try_again = try_again + list (set(pages).difference(set(df.index.values)))\n",
    "try_again"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 暂存档"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:37.550800Z",
     "start_time": "2020-05-17T13:07:37.444813Z"
    }
   },
   "outputs": [],
   "source": [
    "filename = fn [\"output\"] [\"公众号_htm_snippets\"] \n",
    "df_out.to_csv(filename.format(公众号=公众号), sep=\"\\t\", encoding=\"utf8\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:38.611751Z",
     "start_time": "2020-05-17T13:07:38.166430Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14,13,13,13,12,10,12,15,13,13,14,10,11,9,12,7,11,9,8,10,8,9,12,17,16,15,15,13,13,14,9,11,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,14,14,14,15,13,10,11,13,14,14,12,12,14,10,14,13,14,14,13,14,13,14,14,15,18,18,16,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,"
     ]
    }
   ],
   "source": [
    "def parse_html_snippets(_snippet_):\n",
    "    root = fromstring(_snippet_) \n",
    "    title = [x.text for x in root.xpath('//div[@class=\"inner_link_article_title\"]')]\n",
    "    create_time = [x.text for x in root.xpath('//div[@class=\"inner_link_article_date\"]')]\n",
    "    link = [x for x in root.xpath('//a/@href')]\n",
    "    _df_ = pd.DataFrame({\"title\":title, \"create_time\": create_time, \"link\":link})\n",
    "    return(_df_)\n",
    "    \n",
    "l_df = []\n",
    "for p in pages:\n",
    "    _df_ = parse_html_snippets(df.loc[p,\"html_snippets\"])\n",
    "    print (len(_df_), end=\",\")\n",
    "    l_df.append(_df_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:39.839182Z",
     "start_time": "2020-05-17T13:07:39.804198Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>正式服预告③ | 新英雄镜即将登场，将军白起优化升级！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>不负春日时光，峡谷踏青特卖会等你开启！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>季末上分就看ta！冲刺流体系助你驰骋峡谷~</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>狄某有话说丨优化思路大分享，对局体验UP中！</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>猜猜里面都藏着什么？【点击开启】你的王者盲盒！</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>正式服预告① | 玄雍危机降临，S19新赛季来袭！</td>\n",
       "      <td>2020-03-24</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>【送魅语】不知火舞新装登场，参与活动赢永久皮肤！</td>\n",
       "      <td>2020-03-24</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>【猛戳学习新姿势】普通攻击也能抢到风暴龙王！？</td>\n",
       "      <td>2020-03-24</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>不知火舞-魅语特惠来袭，永久英雄/皮肤免费兑换！</td>\n",
       "      <td>2020-03-23</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>心动值+9999！斗鱼荣耀战令邀你开启百万豪礼~</td>\n",
       "      <td>2020-03-23</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                          title create_time  \\\n",
       "0   正式服预告③ | 新英雄镜即将登场，将军白起优化升级！  2020-03-26   \n",
       "1           不负春日时光，峡谷踏青特卖会等你开启！  2020-03-26   \n",
       "2         季末上分就看ta！冲刺流体系助你驰骋峡谷~  2020-03-26   \n",
       "3    正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程  2020-03-25   \n",
       "4        狄某有话说丨优化思路大分享，对局体验UP中！  2020-03-25   \n",
       "5       猜猜里面都藏着什么？【点击开启】你的王者盲盒！  2020-03-25   \n",
       "6     正式服预告① | 玄雍危机降临，S19新赛季来袭！  2020-03-24   \n",
       "7      【送魅语】不知火舞新装登场，参与活动赢永久皮肤！  2020-03-24   \n",
       "8       【猛戳学习新姿势】普通攻击也能抢到风暴龙王！？  2020-03-24   \n",
       "9      不知火舞-魅语特惠来袭，永久英雄/皮肤免费兑换！  2020-03-23   \n",
       "10     心动值+9999！斗鱼荣耀战令邀你开启百万豪礼~  2020-03-23   \n",
       "\n",
       "                                                 link  \n",
       "0   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "1   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "2   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "4   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "5   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "6   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "7   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "8   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "9   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "10  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  "
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out = pd.concat(l_df).reset_index(drop=True)\n",
    "df_url_out.loc[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:07:45.914333Z",
     "start_time": "2020-05-17T13:07:45.906355Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3509</th>\n",
       "      <td>是敌亦是友，与劲敌一起成就王者！</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3510</th>\n",
       "      <td>王者探案集 | 峡谷困兽斗，虎子居然输了？</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>什么？悟空大招音效竟然是石头做出来的……</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                          title create_time  \\\n",
       "3509           是敌亦是友，与劲敌一起成就王者！  2018-06-16   \n",
       "3510      王者探案集 | 峡谷困兽斗，虎子居然输了？  2018-06-16   \n",
       "3511       什么？悟空大招音效竟然是石头做出来的……  2018-06-15   \n",
       "3512  常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！  2018-06-15   \n",
       "3513      上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "\n",
       "                                                   link  \n",
       "3509  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3510  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3511  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3512  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3513  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  "
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:43.807520Z",
     "start_time": "2020-05-17T13:24:43.620223Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>value</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>不负春日时光，峡谷踏青特卖会等你开启！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>猜猜里面都藏着什么？【点击开启】你的王者盲盒！</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>【送魅语】不知火舞新装登场，参与活动赢永久皮肤！</td>\n",
       "      <td>2020-03-24</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>【猛戳学习新姿势】普通攻击也能抢到风暴龙王！？</td>\n",
       "      <td>2020-03-24</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>不知火舞-魅语特惠来袭，永久英雄/皮肤免费兑换！</td>\n",
       "      <td>2020-03-23</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3503</th>\n",
       "      <td>划龙舟赢缤纷独角兽，快来荡起双桨</td>\n",
       "      <td>2018-06-18</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3508</th>\n",
       "      <td>王者炸麦了 | 七局打满，无痕典韦秀翻全场~</td>\n",
       "      <td>2018-06-17</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3509</th>\n",
       "      <td>是敌亦是友，与劲敌一起成就王者！</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3510</th>\n",
       "      <td>王者探案集 | 峡谷困兽斗，虎子居然输了？</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>什么？悟空大招音效竟然是石头做出来的……</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1995 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          title create_time  \\\n",
       "value                                         \n",
       "1           不负春日时光，峡谷踏青特卖会等你开启！  2020-03-26   \n",
       "5       猜猜里面都藏着什么？【点击开启】你的王者盲盒！  2020-03-25   \n",
       "7      【送魅语】不知火舞新装登场，参与活动赢永久皮肤！  2020-03-24   \n",
       "8       【猛戳学习新姿势】普通攻击也能抢到风暴龙王！？  2020-03-24   \n",
       "9      不知火舞-魅语特惠来袭，永久英雄/皮肤免费兑换！  2020-03-23   \n",
       "...                         ...         ...   \n",
       "3503           划龙舟赢缤纷独角兽，快来荡起双桨  2018-06-18   \n",
       "3508     王者炸麦了 | 七局打满，无痕典韦秀翻全场~  2018-06-17   \n",
       "3509           是敌亦是友，与劲敌一起成就王者！  2018-06-16   \n",
       "3510      王者探案集 | 峡谷困兽斗，虎子居然输了？  2018-06-16   \n",
       "3511       什么？悟空大招音效竟然是石头做出来的……  2018-06-15   \n",
       "\n",
       "                                                    link  \n",
       "value                                                     \n",
       "1      http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "5      http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "7      http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "8      http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "9      http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "...                                                  ...  \n",
       "3503   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3508   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3509   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3510   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3511   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "\n",
       "[1995 rows x 3 columns]"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# tagging 标记\n",
    "tagging_list = [\"\",\"KPL\", \"英雄调整\", \"版本你造吗\",\"王者别闹\",\"妲己问答社\",\"上分拍档\",\"策划有话说\",\"峡谷小课堂\",\\\n",
    "                \"新皮肤爆料\",\"正式服预告\",\"COS少女集\", \"体验服爆料\", \"UI改造日志\",\"狄某有话说\",\"明日开赛\",\\\n",
    "                \"新皮免费得\",\"上分秘籍\",\"上分\", \"比赛\", \"王者音乐课\",\"投稿有奖\",\"赢荣耀水晶\",\n",
    "               \"守护记忆\",\"开黑活动\",\"福利\", \"免费皮肤\", \"免费英雄\",\"峡谷哄女友指南\",\"【HOT】\",\"调整\",\"赛事\"] #overwritable\n",
    "\n",
    "v_v_list = []\n",
    "\n",
    "for tag in tagging_list:\n",
    "    index_list = df_url_out [ df_url_out.title.str.contains(tag) ].index.tolist()\n",
    "    v_v_pairs = pd.DataFrame({tag:index_list}).melt().set_index(\"value\")\n",
    "    v_v_list.append(v_v_pairs)\n",
    "\n",
    "df_cat = v_v_list[0]\n",
    "for d in v_v_list:\n",
    "    df_cat.update(d)\n",
    "    \n",
    "# 尚未标记内容\n",
    "df_url_out.loc [ df_cat.query('variable==\"\"').index ]"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "df_url_out.loc[53].link"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:44.826461Z",
     "start_time": "2020-05-17T13:24:44.812527Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>正式服预告③ | 新英雄镜即将登场，将军白起优化升级！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>不负春日时光，峡谷踏青特卖会等你开启！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>季末上分就看ta！冲刺流体系助你驰骋峡谷~</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>狄某有话说丨优化思路大分享，对局体验UP中！</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3509</th>\n",
       "      <td>是敌亦是友，与劲敌一起成就王者！</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3510</th>\n",
       "      <td>王者探案集 | 峡谷困兽斗，虎子居然输了？</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>什么？悟空大招音效竟然是石头做出来的……</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2742 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                            title create_time  \\\n",
       "128   正式服预告③ | 新英雄镜即将登场，将军白起优化升级！  2020-03-26   \n",
       "129           不负春日时光，峡谷踏青特卖会等你开启！  2020-03-26   \n",
       "130         季末上分就看ta！冲刺流体系助你驰骋峡谷~  2020-03-26   \n",
       "131    正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程  2020-03-25   \n",
       "132        狄某有话说丨优化思路大分享，对局体验UP中！  2020-03-25   \n",
       "...                           ...         ...   \n",
       "3509             是敌亦是友，与劲敌一起成就王者！  2018-06-16   \n",
       "3510        王者探案集 | 峡谷困兽斗，虎子居然输了？  2018-06-16   \n",
       "3511         什么？悟空大招音效竟然是石头做出来的……  2018-06-15   \n",
       "3512    常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！  2018-06-15   \n",
       "3513        上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "\n",
       "                                                   link  \n",
       "128   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "129   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "130   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "131   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "132   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "...                                                 ...  \n",
       "3509  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3510  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3511  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3512  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3513  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "\n",
       "[2742 rows x 3 columns]"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out[df_url_out.duplicated()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:45.370970Z",
     "start_time": "2020-05-17T13:24:45.325700Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>正式服预告③ | 新英雄镜即将登场，将军白起优化升级！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>不负春日时光，峡谷踏青特卖会等你开启！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>季末上分就看ta！冲刺流体系助你驰骋峡谷~</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>狄某有话说丨优化思路大分享，对局体验UP中！</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1429</th>\n",
       "      <td>是敌亦是友，与劲敌一起成就王者！</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1430</th>\n",
       "      <td>王者探案集 | 峡谷困兽斗，虎子居然输了？</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1431</th>\n",
       "      <td>什么？悟空大招音效竟然是石头做出来的……</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1432</th>\n",
       "      <td>常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1433</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>772 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                            title create_time  \\\n",
       "0     正式服预告③ | 新英雄镜即将登场，将军白起优化升级！  2020-03-26   \n",
       "1             不负春日时光，峡谷踏青特卖会等你开启！  2020-03-26   \n",
       "2           季末上分就看ta！冲刺流体系助你驰骋峡谷~  2020-03-26   \n",
       "3      正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程  2020-03-25   \n",
       "4          狄某有话说丨优化思路大分享，对局体验UP中！  2020-03-25   \n",
       "...                           ...         ...   \n",
       "1429             是敌亦是友，与劲敌一起成就王者！  2018-06-16   \n",
       "1430        王者探案集 | 峡谷困兽斗，虎子居然输了？  2018-06-16   \n",
       "1431         什么？悟空大招音效竟然是石头做出来的……  2018-06-15   \n",
       "1432    常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！  2018-06-15   \n",
       "1433        上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "\n",
       "                                                   link  \n",
       "0     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "1     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "2     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "3     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "4     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "...                                                 ...  \n",
       "1429  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "1430  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "1431  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "1432  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "1433  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...  \n",
       "\n",
       "[772 rows x 3 columns]"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out[~df_url_out.duplicated()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:45.844458Z",
     "start_time": "2020-05-17T13:24:45.828560Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "      <th>variable</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>正式服预告③ | 新英雄镜即将登场，将军白起优化升级！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>正式服预告</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>不负春日时光，峡谷踏青特卖会等你开启！</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>季末上分就看ta！冲刺流体系助你驰骋峡谷~</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>福利</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>狄某有话说丨优化思路大分享，对局体验UP中！</td>\n",
       "      <td>2020-03-25</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>狄某有话说</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3509</th>\n",
       "      <td>是敌亦是友，与劲敌一起成就王者！</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3510</th>\n",
       "      <td>王者探案集 | 峡谷困兽斗，虎子居然输了？</td>\n",
       "      <td>2018-06-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>什么？悟空大招音效竟然是石头做出来的……</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>KPL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3514 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                            title create_time  \\\n",
       "0     正式服预告③ | 新英雄镜即将登场，将军白起优化升级！  2020-03-26   \n",
       "1             不负春日时光，峡谷踏青特卖会等你开启！  2020-03-26   \n",
       "2           季末上分就看ta！冲刺流体系助你驰骋峡谷~  2020-03-26   \n",
       "3      正式服预告② | 荣耀战令福利更新，峡谷历险即刻启程  2020-03-25   \n",
       "4          狄某有话说丨优化思路大分享，对局体验UP中！  2020-03-25   \n",
       "...                           ...         ...   \n",
       "3509             是敌亦是友，与劲敌一起成就王者！  2018-06-16   \n",
       "3510        王者探案集 | 峡谷困兽斗，虎子居然输了？  2018-06-16   \n",
       "3511         什么？悟空大招音效竟然是石头做出来的……  2018-06-15   \n",
       "3512    常规赛MVP虔诚竟是打野鬼才？KPL战袍重磅发售！  2018-06-15   \n",
       "3513        上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "\n",
       "                                                   link variable  \n",
       "0     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...    正式服预告  \n",
       "1     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...     无法分类  \n",
       "2     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "3     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       福利  \n",
       "4     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...    狄某有话说  \n",
       "...                                                 ...      ...  \n",
       "3509  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...     无法分类  \n",
       "3510  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...     无法分类  \n",
       "3511  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...     无法分类  \n",
       "3512  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...      KPL  \n",
       "3513  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "\n",
       "[3514 rows x 4 columns]"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_o = df_url_out.join(df_cat).replace(\"\", np.nan).fillna(\"无法分类\")\n",
    "df_o"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:46.110822Z",
     "start_time": "2020-05-17T13:24:46.098314Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "      <th>variable</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>季末上分就看ta！冲刺流体系助你驰骋峡谷~</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>点亮守护星，上分更省心！五五开黑节活动福利抢先看</td>\n",
       "      <td>2020-04-24</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>福利</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>新版本今日上线！英雄调整瞬间读懂，上分快人一步</td>\n",
       "      <td>2020-03-31</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>调整</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>116</th>\n",
       "      <td>新赛季上分必看！一图教你玩转镜&amp;白起~</td>\n",
       "      <td>2020-03-31</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>季末上分就看ta！冲刺流体系助你驰骋峡谷~</td>\n",
       "      <td>2020-03-26</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3461</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3474</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3487</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3500</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>上分拍档 | 给我小怪，你的野区我来养猪~</td>\n",
       "      <td>2018-06-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...</td>\n",
       "      <td>上分</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>181 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                         title create_time  \\\n",
       "2        季末上分就看ta！冲刺流体系助你驰骋峡谷~  2020-03-26   \n",
       "58    点亮守护星，上分更省心！五五开黑节活动福利抢先看  2020-04-24   \n",
       "115    新版本今日上线！英雄调整瞬间读懂，上分快人一步  2020-03-31   \n",
       "116        新赛季上分必看！一图教你玩转镜&白起~  2020-03-31   \n",
       "130      季末上分就看ta！冲刺流体系助你驰骋峡谷~  2020-03-26   \n",
       "...                        ...         ...   \n",
       "3461     上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "3474     上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "3487     上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "3500     上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "3513     上分拍档 | 给我小怪，你的野区我来养猪~  2018-06-15   \n",
       "\n",
       "                                                   link variable  \n",
       "2     http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "58    http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       福利  \n",
       "115   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       调整  \n",
       "116   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "130   http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "...                                                 ...      ...  \n",
       "3461  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "3474  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "3487  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "3500  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "3513  http://mp.weixin.qq.com/s?__biz=MzIwMTI1OTI3MA...       上分  \n",
       "\n",
       "[181 rows x 4 columns]"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_o[df_o.title.str.contains(\"上分\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:46.476746Z",
     "start_time": "2020-05-17T13:24:46.466841Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>variable</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>无法分类</th>\n",
       "      <td>1995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>福利</th>\n",
       "      <td>385</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>KPL</th>\n",
       "      <td>349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>上分</th>\n",
       "      <td>178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>妲己问答社</th>\n",
       "      <td>176</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>COS少女集</th>\n",
       "      <td>168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>王者别闹</th>\n",
       "      <td>161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>新皮肤爆料</th>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>狄某有话说</th>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>体验服爆料</th>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>王者音乐课</th>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>赛事</th>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>正式服预告</th>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>峡谷小课堂</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>调整</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>版本你造吗</th>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>【HOT】</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>UI改造日志</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>策划有话说</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>比赛</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>守护记忆</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>明日开赛</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>新皮免费得</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>开黑活动</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>峡谷哄女友指南</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>赢荣耀水晶</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          title\n",
       "variable       \n",
       "无法分类       1995\n",
       "福利          385\n",
       "KPL         349\n",
       "上分          178\n",
       "妲己问答社       176\n",
       "COS少女集      168\n",
       "王者别闹        161\n",
       "新皮肤爆料        29\n",
       "狄某有话说        14\n",
       "体验服爆料        13\n",
       "王者音乐课         9\n",
       "赛事            6\n",
       "正式服预告         6\n",
       "峡谷小课堂         5\n",
       "调整            5\n",
       "版本你造吗         3\n",
       "【HOT】         2\n",
       "UI改造日志        2\n",
       "策划有话说         1\n",
       "比赛            1\n",
       "守护记忆          1\n",
       "明日开赛          1\n",
       "新皮免费得         1\n",
       "开黑活动          1\n",
       "峡谷哄女友指南       1\n",
       "赢荣耀水晶         1"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_stats = df_o.groupby(by=\"variable\").agg({\"title\":\"count\"}).sort_values(by=\"title\", ascending=False)\n",
    "df_stats"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:56.494190Z",
     "start_time": "2020-05-17T13:24:56.490201Z"
    }
   },
   "outputs": [],
   "source": [
    "df_account.columns.name = \"rel_accounts\"\n",
    "df_o.columns.name = \"url_cat\"\n",
    "df_stats.columns.name = \"stats\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:57.462691Z",
     "start_time": "2020-05-17T13:24:57.451721Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'stats'"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_df_.columns.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-05-17T13:24:59.938264Z",
     "start_time": "2020-05-17T13:24:59.092037Z"
    }
   },
   "outputs": [],
   "source": [
    "# Get the xlsxwriter workbook and worksheet objects.  \n",
    "with pd.ExcelWriter(fn[\"output\"][\"公众号_xlsx\"].format(公众号=公众号)) as writer:\n",
    "    workbook  = writer.book\n",
    "\n",
    "    for _df_ in [df_account, df_o, df_stats]:\n",
    "        _df_.to_excel(writer, sheet_name = _df_.columns.name)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "303.837px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
